<template>
	
	<div>
		<home-header></home-header>

		<home-swiper :swiperList='swiperList'></home-swiper>

		<home-icons :iconsList='iconsList'></home-icons>
		<home-advertisement :AdvertisementList='AdvertisementList'></home-advertisement>
		<home-hotList :HotList='HotList' :HotLists='HotLists'></home-hotList>
		<home-guessYou :cainixihuan='cainixihuan' :cainixihuanList='cainixihuanList'></home-guessYou>
	</div>

</template>
<script type="text/javascript">
import {mapState} from 'vuex'
import HomeHeader from './pages/Header'
import HomeSwiper from './pages/Swiper'
import HomeIcons from './pages/Icons'
import HomeAdvertisement from './pages/Advertisement'
import HomeHotList from './pages/HotList'
import HomeGuessYou from './pages/GuessYou'
export default {
	data () {
		return {
			changeCity:'',
			swiperList:[],
			iconsList:[],
			AdvertisementList:[],
			HotList:[],
			HotLists:[],
			cainixihuan:[],
			cainixihuanList:[]
		}
	},
	components:{
		HomeHeader,
		HomeSwiper,
		HomeIcons,
		HomeAdvertisement,
		HomeHotList,
		HomeGuessYou,

	},
	computed : {
		...mapState(['city'])
	}
	,
	methods:{
		getHttp(){
			this.$http.get("/api/HomeList.json")
			.then((res)=>{
				const data = res.data.data.HomeCityList				
				data.forEach((item,index)=>{
					if(item.city == this.city){
				this.swiperList = item.swiperList
				this.iconsList = item.iconsList
				this.AdvertisementList = item.AdvertisementList
				this.HotList = item.HotList
				this.HotLists = item.HotLists
				this.cainixihuan = item.cainixihuan
				this.cainixihuanList = item.cainixihuanList
				
				}
				})

			})
		}
	},
		// this.swiperList = data.swiperList
				// this.iconsList = data.iconsList
				// this.AdvertisementList = data.AdvertisementList
				// this.HotList = data.HotList
				// this.HotLists = data.HotLists
				// this.cainixihuan = data.cainixihuan
				// this.cainixihuanList = data.cainixihuanList

	mounted () {

		this.changeCity=this.city
		this.getHttp();
	},
	activated () {

		if( this.changeCity != this.city){
			this.changeCity=this.city
		 	this.getHttp();
		}

	}
}
</script>